package com.ruoyi.web.controller.pointalarmhistory;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yanjing.domain.PointAlarmHistory;
import com.ruoyi.yanjing.service.IPointAlarmHistoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 监测点位历史告警信息Controller
 * 
 * @author whz
 * @date 2024-11-19
 */
@RestController
@RequestMapping("/yanjing/history")
public class PointAlarmHistoryController extends BaseController
{
    @Autowired
    private IPointAlarmHistoryService pointAlarmHistoryService;

    /**
     * 查询监测点位历史告警信息列表-不分页
     */
    @PreAuthorize("@ss.hasPermi('yanjing:history:selecthistorylist')")
    @GetMapping("/selecthistorylist")
    public AjaxResult selecthistorylist(PointAlarmHistory pointAlarmHistory)
    {
        return success(pointAlarmHistoryService.selectPointAlarmHistoryList(pointAlarmHistory));

    }

    /**
     * 查询监测点位历史告警信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(PointAlarmHistory pointAlarmHistory)
    {
        startPage();
        List<PointAlarmHistory> list = pointAlarmHistoryService.selectPointAlarmHistoryList(pointAlarmHistory);
        return getDataTable(list);
    }

    /**
     * 导出监测点位历史告警信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:history:export')")
    @Log(title = "监测点位历史告警信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PointAlarmHistory pointAlarmHistory)
    {
        List<PointAlarmHistory> list = pointAlarmHistoryService.selectPointAlarmHistoryList(pointAlarmHistory);
        ExcelUtil<PointAlarmHistory> util = new ExcelUtil<PointAlarmHistory>(PointAlarmHistory.class);
        util.exportExcel(response, list, "监测点位历史告警信息数据");
    }

    /**
     * 获取监测点位历史告警信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:history:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(pointAlarmHistoryService.selectPointAlarmHistoryById(id));
    }

    /**
     * 新增监测点位历史告警信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:history:add')")
    @Log(title = "监测点位历史告警信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PointAlarmHistory pointAlarmHistory)
    {
        return toAjax(pointAlarmHistoryService.insertPointAlarmHistory(pointAlarmHistory));
    }

    /**
     * 修改监测点位历史告警信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:history:edit')")
    @Log(title = "监测点位历史告警信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PointAlarmHistory pointAlarmHistory)
    {
        return toAjax(pointAlarmHistoryService.updatePointAlarmHistory(pointAlarmHistory));
    }

    /**
     * 删除监测点位历史告警信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:history:remove')")
    @Log(title = "监测点位历史告警信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(pointAlarmHistoryService.deletePointAlarmHistoryByIds(ids));
    }
}
